<!--订单列表页面-->
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head >
    <meta charset="UTF-8">
    <title>Title</title>
    <!--静态路径-->
    <!-- <link rel="stylesheet" type="text/css" href="../../static/layuiadmin/layui/css/layui.css" media="all">
     <link rel="stylesheet" type="text/css" href="../../static/layuiadmin/style/admin.css" media="all">
     <script type="text/javascript" src="../../static/layuiadmin/layui/layui.js"></script>-->
    <link rel="stylesheet" type="text/css"th:href="@{/layuiadmin/layui/css/layui.css}" media="all">
    <link rel="stylesheet" type="text/css" th:href="@{/layuiadmin/style/admin.css}" media="all">
    <script type="text/javascript" th:src="@{/layuiadmin/layui/layui.js}"></script>
    <style>
        .allView{
            text-align: center;
            font-size: 2em;
            line-height: 160px;
            color: #57a88b;

            border-radius: 5px;
        }
        .distance{
            border: 1px solid #e29f2a;
            margin-top: 20px;
            font-size: 1em;
            text-align: center;
            color: #070000;
        }
        .top{

            margin-top: -5%;
        }
        .text{
            background-color: rgb(255, 255, 251);
        }
        hr{
            width: 80%;
        }
        .p_hr{
            margin-top: 15px;
        }
        .right-text{
            text-align: center;
            margin-left: 20%;
            color: red;
        }

    </style>

</head>
<body>
<div class="layui-fluid">

    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">

                <div class="layui-card-header">订单列表</div>
                <div class="layui-card-body">
                    <table class="layui-hide" id="demo" lay-filter="demo"></table>
                </div>
            </div>
        </div>
    </div>

    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
</div>
<!--//编辑弹框-->
<div style="display: none;" id="dome">
    <form  class="layui-form" lay-filter="form1" id="form1" action="">

        <div class="layui-form-item" style="margin-top: 20px;">
            <label class="layui-form-label">商品名称</label>
            <div class="layui-col-md7 layui-col-sm7">
                <input type="text" name="name" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" >
            <label class="layui-form-label">商品分类</label>
            <div class="layui-col-md7 layui-col-sm7">
                <select name="category" id="">
                    <option value="">请选择</option>
                    <option value="1">零食</option>
                    <option value="2">临期</option>
                    <option value="3">特价</option>

                </select>
            </div>
        </div>
        <div class="layui-form-item" >
            <label class="layui-form-label">副标题</label>
            <div class="layui-col-md7 layui-col-sm7">
                <input type="text" name="secTitle" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" >
            <label class="layui-form-label">商品货号</label>
            <div class="layui-col-md7 layui-col-sm7">
                <input type="text" name="no" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style>
            <label class="layui-form-label">商品售价</label>
            <div class="layui-col-md7 layui-col-sm7">
                <input type="text" name="price" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style>
            <label class="layui-form-label">商品库存</label>
            <div class="layui-col-md7 layui-col-sm7">
                <input type="text" name="Number" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-col-md-offset1">
            <div class="layui-input-block layui-btn-group ">
                <button class="layui-btn" lay-submit lay-filter="form1">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script>
    layui.use(['element','table','jquery','form'] ,function(){
        var element = layui.element,
            table = layui.table,
            form = layui.form,
            $= layui.$
        ;
        table.render({
            elem: '#demo'
            //,skin: 'line' //表格风格
            ,even: true
            ,page: true //是否显示分页
            ,limits: [2, 7, 10]
            ,limit: 10 //每页默认显示的数量
            ,url:'getSaleAll'
            ,id: 'testReload'
            ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            ,cols: [
                [
                    {type:'checkbox'},
                    {field:'orderNo', width:'10%', title: '订单id', sort: true},
                    {field:'custId', width:'10%', title: '顾客id', },
                    {field:'invoiceNo', width:'10%', title: '订单编号', },
                    {field:'orderDate', width:'10%', title: '下单日期', },
                    {field:'order', width:'10%', title: '是否付款',templet: function(d){
                            if (d.orderStatus ==0)
                                return '<span style="color: #c00;">'+ '未付款' +'</span>'
                            else if(d.orderStatus ==1)
                                return '<span style="color: #12f137;">'+ '已付款' +'</span>'
                            else if(d.orderStatus ==2)
                                return '<span style="color: #f3302a;">'+ '申请退款' +'</span>'
                            else if(d.orderStatus ==3)
                                return '<span style="color: #66cc50;">'+ '已退款' +'</span>'
                            else if(d.orderStatus ==4)
                                return '<span style="color: #f3302a;">'+ '拒绝退款' +'</span>'
                        } },
                    {field:'totAmt', width:'10%', title: ' 总额',},
                    { field: 'right',title: '操作',toolbar: "#barDemo",fixed: 'right'}
                ]
            ]
            , response: {
                statusName: 'code',
                statusCode: '1',
                msgName: 'msg',
                countName: 'total',
                dataName: 'data'
            },  request: {
                pageName: 'currentPage', // 当前页
                limitName: 'pageSize' // 每页面显示多少条
            },
        });

        table.on('tool(demo)', function(obj) {
            var data = obj.data
            console.log(data)
            if (obj.event ==='detail'){
               document.location.href = 'orderDetails?no='+data.invoiceNo
            }else if(obj.event==='del'){ //删除
                layer.confirm('确认删除',function(){
                    $.ajax({
                        type:"post",
                        url:'delAdminOrder',
                        data:{invoiceNo:data.invoiceNo},
                        dataType:'json',
                        success:function (res) {
                           console.log(res)
                            if (res.code == 1){
                                layer.msg(res.msg,{icon:6},function () {
                                    window.location.reload()
                                })
                            } else{
                                layer.msg(res.msg,{icon:5})
                            }
                        }
                    })
                })

            }
        })
        //…
        $('.layui-btn').on('click',function () {
            document.location.href = 'addGoods'
        })

    });
</script>
</body>
</html>